package vlms.dao;

import java.sql.*;

import vlms.exception.SimplecustomerRecordCountException;

public class SimplecustomerRecordCountDAO {
	public SimplecustomerRecordCountDAO() {
	}

	public SimplecustomerRecordCount getRecordCount(Connection con)
			throws SimplecustomerRecordCountException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			stmt = con.prepareStatement("SELECT COUNT(*) FROM SIMPLECUSTOMER");
			rs = stmt.executeQuery();
			rs.next();
			SimplecustomerRecordCount vo = new SimplecustomerRecordCount();
			vo.setCount(rs.getInt(1));
			return vo;
		} catch (SQLException sqle) {
			throw new SimplecustomerRecordCountException(sqle);
		} catch (Exception e) {
			throw new SimplecustomerRecordCountException(e);
		}
	}

	public SimplecustomerRecordCount getRecordCount(Connection con,
			String whereClause) throws SimplecustomerRecordCountException {
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			stmt = con.prepareStatement("SELECT COUNT(*) FROM SIMPLECUSTOMER  "
					+ whereClause);
			rs = stmt.executeQuery();
			rs.next();
			SimplecustomerRecordCount vo = new SimplecustomerRecordCount();
			vo.setCount(rs.getInt(1));
			return vo;
		} catch (SQLException sqle) {
			throw new SimplecustomerRecordCountException(sqle);
		} catch (Exception e) {
			throw new SimplecustomerRecordCountException(e);
		}
	}
}
